package com.qf.purchase.service;

import com.github.pagehelper.PageInfo;
import com.qf.purchase.dao.PurchaseOrderDao;
import com.qf.purchase.po.PurchaseOrder;
import com.qf.purchase.po.PurchaseOrderCount;
import com.qf.purchase.service.PurchaseOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class PurchaseOrderServiceImpl implements PurchaseOrderService {

    @Resource
    private PurchaseOrderDao purchaseOrderdao;

    public boolean addPurchaseOrder(PurchaseOrder purchaseOrder) {
        boolean f=purchaseOrderdao.addPurchaseOrder(purchaseOrder) > 0?true:false;
        return f;
    }

    @Override
    public PageInfo<PurchaseOrder> getAllPurchaseOrderByPage(Map params) {
        List<PurchaseOrder> purchaseOrderList=purchaseOrderdao.getAllPurchaseOrderByPage(params);
        PageInfo<PurchaseOrder> pageInfo = new PageInfo<PurchaseOrder>(purchaseOrderList);
        return pageInfo;
    }

    @Override
    public boolean updatePurchaseOrder(PurchaseOrder purchaseOrder) {
        return purchaseOrderdao.updatePurchaseOrder(purchaseOrder)>0;
    }

    @Override
    public boolean delPurchaseOrder(String number) {
        return purchaseOrderdao.delPurchaseOrder(number)>0;
    }

    @Override
    public boolean delAllPurchaseOrderDetails(String number) {
        return purchaseOrderdao.delAllPurchaseOrderDetails(number)>0;
    }

    @Override
    public PurchaseOrder findPurchaseOrderByNumber(String number) {
        return purchaseOrderdao.findPurchaseOrderByNumber(number);
    }


    @Override
    public PageInfo<PurchaseOrderCount> getCountByPage(Map params) {
        List<PurchaseOrderCount> purchaseOrderCounts=purchaseOrderdao.getCountByPage(params);
        PageInfo<PurchaseOrderCount> pageInfo = new PageInfo<PurchaseOrderCount>(purchaseOrderCounts);
        return pageInfo;
    }

    @Override
    public PageInfo<PurchaseOrderCount> getCount(Map params) {
        List<PurchaseOrderCount> purchaseOrderCounts=purchaseOrderdao.getCount(params);
        PageInfo<PurchaseOrderCount> pageInfo = new PageInfo<PurchaseOrderCount>(purchaseOrderCounts);
        return pageInfo;
    }
}
